package com.toycloud.business.controller.selectJson;

import com.toycloud.business.domain.bo.DemandLogBo;
import com.toycloud.business.domain.vo.DemandLogVo;
import com.toycloud.business.service.IDemandLogService;
import com.toycloud.business.service.ISelectJsonService;
import com.toycloud.common.core.controller.BaseController;
import com.toycloud.common.core.domain.PageQuery;
import com.toycloud.common.core.domain.R;
import com.toycloud.common.core.page.TableDataInfo;
import com.toycloud.common.core.utils.poi.RuoyiExcelUtil;
import com.toycloud.common.core.validate.AddGroup;
import com.toycloud.common.core.validate.EditGroup;
import com.toycloud.system.domain.selectJson.SelectJsonReocrd;
import com.toycloud.system.domain.selectJson.vo.SelectJsonRecordVo;
import com.toycloud.system.log.annotation.Log;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;


/**
 * SelectJsonRecord
 *
 * @author binlu6
 * @date 2024-11-06
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/project/selectJson")
@Slf4j
public class SelectJsonController extends BaseController {

    private final ISelectJsonService iSelectJsonService;
    

    /**
     * 获取demandLog详细信息
     *
     * @param id 主键
     */
    @GetMapping("/{id}")
    public R<String> getInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable String id) {
        return R.ok(iSelectJsonService.queryById(id));
    }

    public Void get(){
        iSelectJsonService.deleteRecord();
        return null;
    }
    

    /**
     * 新增demandLog
     */
    @Log(title = "SelectJsonRecord")
    @PostMapping()
    public R<String> add(HttpServletRequest request, @Validated(AddGroup.class) @RequestBody SelectJsonReocrd selectJsonReocrd) {
        return R.ok(iSelectJsonService.insertByBo(selectJsonReocrd));
    }

    /**
     * 修改demandLog
     */
    @Log(title = "SelectJsonRecord")
    @PutMapping()
    public R<Void> edit(HttpServletRequest request,@Validated(EditGroup.class) @RequestBody SelectJsonReocrd selectJsonReocrd) {
        return toAjax(iSelectJsonService.updateByBo(selectJsonReocrd));
    }

    /**
     * 删除demandLog
     *
     * @param ids 主键串
     */
    @Log(title = "SelectJsonRecord")
    @DeleteMapping("/{ids}")
    public R<Void> remove(@NotEmpty(message = "主键不能为空")
                          @PathVariable Long[] ids) {
        return toAjax(iSelectJsonService.deleteWithValidByIds(Arrays.asList(ids), true));
    }

}
